-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[golang] Fix Null pointer exception in toVarName #377
[golang] Fix Null pointer exception in toVarName #377
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me.
thanks for the PR!
// replace - with _ e.g. created-at => created_at | ||
name = sanitizeName(name.replaceAll("-", "_")); | ||
name = sanitizeName(name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will sanitizeName() always return a non-null object?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@macjohnny super
will always return non null
. If name
is null
it will return ERROR_UNKNOWN
This is a different issue tracked here #376
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, so then this should be fine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why that replaceAll is here at all? Go should not use _
or -
in variable names. Camelize removes both these.
// Remove all underscores (underscore_case to camelCase)
p = Pattern.compile("(_)(.)");
m = p.matcher(word);
while (m.find()) {
String original = m.group(2);
String upperCase = original.toUpperCase();
if (original.equals(upperCase)) {
word = word.replaceFirst("_", "");
} else {
word = m.replaceFirst(upperCase);
}
m = p.matcher(word);
}
// Remove all hyphens (hyphen-case to camelCase)
p = Pattern.compile("(-)(.)");
m = p.matcher(word);
while (m.find()) {
word = m.replaceFirst(m.group(2).toUpperCase());
m = p.matcher(word);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could update this.
Sounds good, thanks! |
Fix small typo in README
PR checklist
./bin/
to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.sh
and./bin/security/{LANG}-petstore.sh
if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in.\bin\windows\
.master
,3.1.x
,4.0.x
. Default:master
.Description of the PR
Fix null pointer exception when the request body parameter is an array of primitives or maps.
Fixes #373
@wing328 @antihax @bvwells